home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / HLUpdate.rexx < prev    next >
OS/2 REXX Batch file  |  1992-10-22  |  4KB  |  164 lines

  1. /*
  2.  * HLUpdate.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: April 18, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.02
  9.  */
  10.  
  11. /*
  12.  * open rexxsupport.library -- needed for some functions
  13.  */
  14. if ~show('L',"rexxsupport.library") then do
  15.   if addlib('rexxsupport.library',0,-30,0) then do
  16.       /* everything's ok */
  17.     end;
  18.   else do
  19.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  20.     say 'Cannot operate HLUpdate.rexx without this library - sorry!';
  21.     exit 10;
  22.     end;
  23.   end;
  24.  
  25. /*
  26.  * This will automatically direct the script to the proper
  27.  * software, if it is running.
  28.  */
  29. prtnme = 'IP_Port'; /* assume Image Professional */
  30. if show('P','IP_Port') = 0 then do
  31.   if show('P','IM_Port') = 0 then do
  32.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  33.     say "This script requires IP, IM or IM F/c to run!";
  34.     exit(20);
  35.     end;
  36.   else do
  37.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  38.     end;                 /* We make em, user's break em.          */
  39.   end;
  40.  
  41.   /*
  42.    * This code attempts to read a file called "picmdpath" from REXX:
  43.    * If it can't find it, the script will assume that the commands
  44.    * associated with this PI Module are in "c:". If the file exists,
  45.    * the script will look in the path that is specified in the file.
  46.    * If you create this file, you MUST put a complete, correct path
  47.    * in it; if the commands are in a sub-directory, you have to put
  48.    * the trailing slash on the path (like, device:dir/).
  49.    * 
  50.    */
  51.   cmdpath = 'c:';
  52.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  53.     do
  54.       cmdpath = readln(fhandle);
  55.       call close(fhandle);  /* close the file    */
  56.     end
  57.  
  58. options;
  59. address;
  60.  
  61.   address(prtnme);
  62.   options results;
  63.   'current';
  64.   bufdata = result; /* get name of buffer, if there is one */
  65.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  66.   if bname ~= '<none>' then do
  67.     bufname = bname;
  68.     end;
  69.  
  70.   address(prtnme);
  71.  
  72. 'tofront';
  73.  
  74. options results;
  75. 'gadgets "Update","as RGB","Update","as CMYK","Update","as GREY","Update","as B&W"';
  76. ptype = result-1;
  77. options;
  78. if ptype < 0 then do
  79.   address;
  80.   exit 0;
  81.   end
  82.  
  83.   if ptype < 3 then do
  84.     options results;
  85.     'askprop '||'"Number of bitplanes per color channel?" 8 1 8'
  86.     planes = result;
  87.     options;
  88.   end
  89.  
  90.   if ptype = 3 then do
  91.     options results;
  92.     'askprop '||'"Luma threshold for black level?" 50 1 100'
  93.     planes = result;
  94.     options;
  95.   end
  96.  
  97.   options results;
  98.   'jackin';
  99.   jackadr = result;
  100.   options;
  101.  
  102.   'wbtofront';
  103.   'lockimage '||bnum;
  104.   address command cmdpath||'HLUpdate '||jackadr||' '||ptype||' '||planes;
  105.   'unlockimage '||bnum;
  106.  
  107.   address(prtnme);
  108.   'imtofront';
  109.   address;
  110.  
  111.   exit 0;
  112.  
  113. /*
  114.  * gimmepath
  115.  *
  116.  * This takes the provided argument and sucks the path out of it, then
  117.  * returns that path to the caller, sans file name.
  118.  */
  119. gimmepath:
  120.   arg fullnamegx;
  121.     tempgx = reverse(fullnamegx);
  122.     lengx = length(fullnamegx);   /* get length of string */
  123.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  124.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  125.     seploc = 0; /* assumes current dir, no path supplied */
  126.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  127.       seploc = (lengx - slashdex)+1;
  128.       end;
  129.     else do
  130.       if colondex ~= 0 then do /* we assume we are on a device */
  131.         seploc = (lengx - colondex)+1;
  132.         end;
  133.       end;
  134.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  135.   gxpath = left(fullnamegx,seploc);
  136.   return(gxpath);
  137.  
  138. /*
  139.  * Since this script can't be expected to know where the CD of the user
  140.  * is when this cmd is invoked, we have to check the path the user
  141.  * provides - if it's not specified right from a root, then we have
  142.  * to make it a complete specification from the root.
  143.  */
  144. expandfilename:
  145.   parse arg jfile;
  146.   if index(jfile,':') = 0 then do
  147.     curdir = pragma(D);
  148.     if right(curdir,1) ~= ':' then do
  149.       if right(curdir,1) ~= '/' then do
  150.         if curdir ~= '' then do
  151.           curdir = curdir || '/';
  152.           end;
  153.         end;
  154.       end;
  155.     jfile = curdir||jfile;
  156.     end;
  157.   return(jfile);
  158.  
  159. rvalue:
  160.   wordnum = c2d(readch(fhandle,1)) * 256;
  161.   wordnum = wordnum + c2d(readch(fhandle,1));
  162.   return wordnum;
  163.  
  164.